package com.example.orderconsumer.config;

import com.example.orderconsumer.bean.Product;
import com.example.orderconsumer.service.ProductService;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class ProductServiceFallbackFactory implements FallbackFactory<ProductService> {
    @Override
    public ProductService create(Throwable cause) {
        return new ProductService() {
            @Override
            public Product findById(Long id) {
                Product product = new Product();
                product.setId(-1L);
                product.setName("Not found");
                return product;
            }
        };
    }
}